package com.kbbywyclient.util;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by Jiangzx on 2017/4/25.
 */

public class OkHttpUtils {
    private static final long CONNECTION_TIME_OUT=60L;
    private static final long READ_TIME_OUT =60L;
    private static final TimeUnit TIME_UNIT=TimeUnit.SECONDS;
    private OkHttpUtils(){

    }

    private static OkHttpClient okHttpClient;

    public static OkHttpClient getOkHttpClient(){
        if(okHttpClient==null){
            synchronized (OkHttpUtils.class){
                if(okHttpClient==null){
                    okHttpClient=new OkHttpClient.Builder().
                            connectTimeout(CONNECTION_TIME_OUT,TIME_UNIT).
                            readTimeout(READ_TIME_OUT,TIME_UNIT).
                            build();
                }
            }
        }
        return okHttpClient;
    }

}
